`
https://leetcode.cn/problems/second-minimum-node-in-a-binary-tree/
`

/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */
var findSecondMinimumValue = function (root) {
  // 如果该结点是叶子结点，直接返回 -1
  if (root.left === null && root.right === null) return -1

  let left = root.left.val, right = root.right.val
  // 如果结点值和左子节点值相同，去左子节点找
  if (left === root.val) left = findSecondMinimumValue(root.left)
  // 如果节点值和右子节点值相同，去右子节点找
  if (right === root.val) right = findSecondMinimumValue(root.right)

  if (left === -1) return right
  if (right === -1) return left

  return Math.min(left, right)
};